<template>
	<view>
		<navbar :title="$t('funding.title')" :background="$utypeprimary" :titleColor="$utitlecolor" :backColor="$utitlecolor">
		 </navbar>
		 <view class="yellow">
		 	<view class="total">
		 		{{userInfo.money}}
		 	</view>
			<view class="balance">
				{{$t("funding.balance")}}
			</view>
		 </view>
		 <view class="white">
		 	<view class="box1">
		 		<view class="revenuesum">
		 			{{total.inc}}
		 		</view>
				<view class="revenue">
					{{$t("funding.revenue")}}
				</view>
		 	</view>
			<view class="box2">
				<view class="spendsum">
					{{total.dec}}
				</view>
				<view class="spend">
					{{$t("funding.spend")}}
				</view>
			</view>
		 </view>
		 <view class="yuan1">
		 	
		 </view>
		 <view class="detail">
		 	<view class="yuan2">
		 		
		 	</view>
			<view class="detailtext">
				{{$t("funding.detail")}}
			</view>
		 </view>
		 <mescroll-body ref="mescrollRef" @up="upCallback" @init="mescrollInit" @down="downCallback"
			:down="downOption" :up="upOption">
			<view>
				<view class="list" v-for="item in list" :key="item.index">
					<view class="photo">
						<image :src="item.icon" mode=""
						style="width: 80rpx;height: 80rpx;"></image>
					</view>
					<view class="explain">
						<view class="top">
							<view class="type">
								{{item.typename}}
							</view>
							<view class="green" :class="{red: item.mold=='dec'}">
								{{item.money}}
							</view>
						</view>
						<view class="bottom">
							<view class="time">
								{{item.createtime}}
							</view>
							<view class="bottomsum">
								{{$t('common.balance')}}:{{$currency}}{{item.after}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import {
		moneytotal,
		moneylist
	} from '@/api/user.js'
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue";
	export default{
		mixins: [MescrollMixin],
		components: {
			MescrollBody
		},
		data() {
			return {
				list:[],
				total: {},
				downOption: {
					use: true,
					auto: true
				},
				upOption: {
					use: true,
					auto: true,
					page: {
						num: 0,
						size: 10
					}
				},
			};
		},
		onLoad() {
			// this.loadList();
			this.loadTotal();
		},
		computed: {
			userInfo() {
				return this.$store.getters.userInfo || {}
			}
		},
		methods: {
			async upCallback(page) {
				let pageNum = (page.num - 1) * page.size
				let pageSize = page.size
				// withdrawlog({
				// 	page: 1,
				// }).then(res => {
				// 	let curPageData = res.list
				// 	let curPageLength = curPageData.length
			
				// 	let totalSize = +res.count
			
				// 	if (page.num == 1) this.addressList = []
				// 	this.addressList = this.addressList.concat(curPageData)
					
			
				// }).catch(err => {
					// 	this.mescroll.endErr()
				// })
				let result = await moneylist({
					page: page.num
				})
				if (page.num == 1) this.list = []
				this.list = this.list.concat(result)
				let curPageLength = result.length
				this.mescroll.endSuccess(curPageLength)
			},
			async loadList() {
				let result = await moneylist({
					page: 1
				})
				this.list = result;
			},
			async loadTotal() {
				let result = await moneytotal();
				this.total = result;
			}
		}
	}
</script>
<style lang="scss">
	page{
		background-color: #F6F6F6FF;
	}
</style>
<style lang="scss" scoped>
	.yellow{
		overflow: hidden;
		height: 271rpx;
		background-color: $u-type-primary;
		.total{
			margin-top: 40rpx;
			text-align: center;
			font-size: 70rpx;
			font-family: Alibaba PuHuiTi;//rubick;
			font-weight: 400;
			color: #0F0F0E;
			line-height: 70rpx;
			
		}
		.balance{
			margin-top: 20rpx;
			text-align: center;
			font-size: 32rpx;
			font-family: Rubik;
			font-weight: 300;
			color: #0F0F0E;
			line-height: 32rpx;
		}
	}
	
	.white{
		display: flex;
		width: 670rpx;
		height: 144rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		margin: -72rpx 40rpx 0;
		text-align: center;
		.box1{
			.revenuesum{
				margin-top: 26rpx;
				width: 335rpx;
				font-size: 48rpx;
				font-family: Alibaba PuHuiTi;//rubick;
				font-weight: 400;
				color: #0F0F0E;
				line-height: 48rpx;
			}
			.revenue{
				margin-top: 16rpx;
				font-size: 29rpx;
				font-family: Rubik;
				font-weight: 300;
				color: #878D9C;
				line-height: 29rpx;
			}
		}
		.box2{
			.spendsum{
				margin-top: 26rpx;
				width: 335rpx;
				font-size: 48rpx;
				font-family: Alibaba PuHuiTi;//rubick;
				font-weight: 400;
				color: #0F0F0E;
				line-height: 48rpx;
			}
			.spend{
				margin-top: 16rpx;
				font-size: 29rpx;
				font-family: Rubik;
				font-weight: 300;
				color: #878D9C;
				line-height: 29rpx;
			}
		}
	}
	
	.yuan1{
		margin-top: 50rpx;
		margin-left: 66rpx;
		width: 16rpx;
		height: 16rpx;
		background: $u-type-primary;
		border-radius: 50%;
	}
	.detail{
		display: flex;
		font-size: 32rpx;
		font-family: Rubik;
		font-weight: 500;
		color: #0F0F0E;
		.yuan2{
			width: 30rpx;
			height: 30rpx;
			background: $u-type-primary;
			border-radius: 50%;
			margin-left: 40rpx;
			
		}
		.detailtext{
			margin-top: -8rpx;
			margin-left: -5rpx;
			margin-bottom: 19rpx;
			
		}
	}
	
	.list{
		display: flex;
		padding: 40rpx;
		border-bottom: 2rpx solid  #ECECEC;
		.explain{
			margin-left: 28rpx;
			.top{
				display: flex;
				font-size: 32rpx;
				font-family: Rubik;
				justify-content: space-between;
				font-weight: 400;
				color: #0F0F0E;
				width: 561rpx;
				.green{
					color: #17CD0A;
				}
				.red{
					color: #FC3E32;
				}
			}
			.bottom{
				display: flex;
				justify-content: space-between;
				align-items: center;
				font-family: Rubik;
				font-weight: 400;
				color: #AAAAAA;
				margin-top: 15rpx;
				.time{
					font-size: 26rpx;
					line-height: 34rpx;
				}
				.bottomsum{
					font-size: 26rpx;
					line-height: 34rpx;
				}
			}
		}
		
	}
</style>
